<%@ taglib prefix="c"   uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@page import = "com.db4o.servlet.Db4oServlet" %>
<%@page import = "facades.*" %>
<%@page import = "auser.*" %>
<%@page import = "com.db4o.query.*" %>
<% SessionFacade sfacade = new SessionFacade(session); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet"  href="<%=request.getContextPath()%>/css/display.css" type="text/css" media="screen" />
<script src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script src="<%=request.getContextPath()%>/js/form.js"></script>
<script type="text/javascript" src='<%=request.getContextPath()%>/js/input01.js'></script>
<title>Gestione Auser - Ricerca Socio per modifica</title>
</head>
<body>
		 	 		 
	 <form method="post" action="searchedit.jsp">
		<h1>Ricerca Socio per modifica</h1> 
		<fieldset>
			<legend>Dati per ricerca</legend> 
	 		<label for='cognome'>Cognome</label><input type="text" name="cognome" id="cognome" size="45" value="${param.cognome}" /><br/>
	 		<label for='nome'>Nome</label><input type="text" name="nome" id="nome"  size="45" value="${param.nome}" /><br/>
	 		<input class='button' type='submit' value='Cerca' id='btnSave' /> 
			<input class='button' type='button' value='Chiudi' id='btnClose' onclick='document.location="<%=request.getContextPath()%>/app/start/index.jsp"'>
	 	</fieldset>
	 	
	 	<c:if test="${!empty param.cognome || !empty param.nome}">
			<% Query qu = sfacade.newQuery(auser.Socio.class); %>
			<% Utente utente = (Utente)session.getAttribute("userBean"); %>	
			<% qu.descend("circolo").constrain(utente.getCircolo());  %>
			<% qu.descend("cognome").constrain(request.getParameter("cognome")).like();  %>
			<% qu.descend("nome").constrain(request.getParameter("nome")).like();  %>
		 	<% qu.descend("cognome").orderAscending().descend("nome").orderAscending();  %>
		 	
		 	<div class='howtomsg'>Fai un click sul Cognome del socio per modificarlo</div>
		 	
		 	<fieldset class='searchResult'>
				<legend>Risultati</legend> 
				<ul>
					<%  int co=0;  %>
			 		<c:forEach items="<%=qu.execute()%>" var="socio" varStatus="status">
						<li><a href='loader.jsp?id=<%=sfacade.getID("socio",pageContext) %>'><b>${socio.cognome} ${socio.nome}</b>  ${socio.comune}  </a> </li>
						<% co++; %>
					</c:forEach>
					<%  if(co==0) { %>
						<li>Nessun socio trovato</li>
					<%  } // if co==0 %>
				</ul>
		 	</fieldset>
	 	</c:if>
	 </form>

	
</body>
</html>